//
//  JobSeekerViewController.m
//  MyProject
//
//  Created by 石小强 on 2018/3/26.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "JobSeekerViewController.h"
#import "PositionSelectViewController.h"
#import "SalarySelectViewController.h"
#import "SearchCompanyViewController.h"
#import "SelectCityViewController.h"
#import "NSUDManager.h"
#import "AppDelegate.h"
#import "JobModel.h"

@interface JobSeekerViewController ()

@end

@implementation JobSeekerViewController {
    JobModel *_selectJob;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"选择角色";
    
    self.shadowV.layer.shadowColor = [UIColor blackColor].CGColor;
    //    self.shadowV.layer.shadowOffset = CGSizeMake(4, 4);
    self.shadowV.layer.shadowOffset = CGSizeMake(0, 0);
    self.shadowV.layer.shadowOpacity = 0.2;
    self.shadowV.layer.shadowRadius = 10.f;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(CitySearchEvent:) name:@"SearchCity" object:nil];
}

- (void)CitySearchEvent:(NSNotification *)notification {
    // 得到传递的参数
    NSDictionary *dict = [notification userInfo];
    self.cityL.text = [dict objectForKey:@"city"];
}


- (IBAction)jobBtnClick:(id)sender {
    PositionSelectViewController *psVC = [[PositionSelectViewController alloc] init];
    psVC.selectBlock = ^(JobModel *job) {
        _selectJob = job;
        self.jobL.text = job.jobName;
    };
    [self.navigationController pushViewController:psVC animated:YES];
}

- (IBAction)cityBtnClick:(id)sender {
    SelectCityViewController *scVC = [[SelectCityViewController alloc] init];
//    scVC.cityBlock = ^(NSString *city) {
//        self.cityL.text = city;
//    };
    [self.navigationController pushViewController:scVC animated:YES];
}

- (IBAction)salaryBtnClick:(id)sender {
    SalarySelectViewController *salary = [[SalarySelectViewController alloc] init];
    salary.selectBlock = ^(NSString *minSalary, NSString *maxSalary) {
        self.salaryL.text = [NSString stringWithFormat:@"%@-%@", minSalary, maxSalary];
    };
    // 核心代码
    self.definesPresentationContext = YES;
    salary.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [self.navigationController presentViewController:salary animated:NO completion:nil];
}

- (IBAction)companyBtnClick:(id)sender {
    SearchCompanyViewController *scVC = [[SearchCompanyViewController alloc] init];
    scVC.index = 0;
    scVC.companyOrCityBlock = ^(NSString *companyOrCity) {
        self.companyL.text = companyOrCity;
    };
    [self.navigationController pushViewController:scVC animated:YES];
}


- (IBAction)okBtnClick:(id)sender {
    UserModel *user = [NSUDManager currentUser];
    user.role = @"1";
    [NSUDManager setCurrentUser:user];
    
    [((AppDelegate *)[UIApplication sharedApplication].delegate) gotoHome];
}

@end
